﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LibraryManagementSystem
{
    public partial class LoginInterface : Form
    {
        public LoginInterface()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)      //注册界面
        {
            RegistrationEvent registration = new RegistrationEvent();
            registration.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text;
            var pwd = textBox2.Text;
            var sql = string.Format("select * from Users where Username='{0}' and  Password='{1}'",uid,pwd);
            var dt = DbHelper.GetData(sql);
            if (dt.Rows.Count == 1)
            {
                MessageBox.Show("登录成功！");
                UserInterface userInterface = new UserInterface();
                userInterface.Show();       //登录成功跳转用户界面
                this.Hide();
            }
            else
            {
                MessageBox.Show("登录失败！用户名或者密码错误！");
            }


            
        }
    }
}
